from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import get_game

class Fail(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # build list of actions
        self.add_action(North)
    
    # return description of room.
    def get_description(self):
        return '''
        You've reached a dead-end. Ya don't have ta go home, butcha can't stay here.
        '''
    
    # return image of room
    def get_image(self):
        return 'Deadend.jpg'
        #return 'binary_monster.jpg'
    
    def get_image_width(self):
        return 'width=100%'

    def has_translator(self):
        
        game = get_game()
            
        # does the player have ASCII from the register?
        player = game.get_player()
        
        if "Translator" in player.inventory:
            return True
        # if we get here, player does not have ASCII
        return False
    
class FailHandler(BaseHandler):
    
    def get_template(self):
        return 'cpu.html'
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Fail

# define actions for this room

class North(Action):
    
    def __init__(self):
        Action.__init__(self, "North")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        game = get_game()
        room = game.get_room("fail", Fail)
        if room.has_translator():
            return "Go North"
        else:
            return "11"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'cpu'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
